﻿using KINLO.Data.Reporitory;
using KINLO.DRV.Drv;
using KINLO.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;


namespace ConsoleApp2
{
    class Program
    { 

        static Socket socket =  new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        // private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
        private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        static DBClass  db = new DBClass();
        static WeightReporitory DB1 = new WeightReporitory();
        static IVModbusDrv PLC;

        static void Main(string[] args)
        {
            var vaken= VekenDll.DataAbstr.GetInstance();
             var A = vaken.GetData("D01-OINJ-01", "C16CA09TAD00099");
            // var A11 = vaken.GetData("FC16BH20TAC00041");
            // var A1 = vaken.GetData("FC16B113TAC00107");
            // var AC = vaken.GetTechnologyStandard("C16");
            // var AC1 = vaken.GetTechnologyStandard("FC1");
            //FC16B113TAC00107 
            Console.WriteLine("asfdasdf");            
            Console.Read();
        }
        static int count = 0;
        private static void T_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            Thread.Sleep(200);
            Console.WriteLine("count:{0}",count++);
        }

        public static Int16 HexToDecimal(string hex)
        {
            var b = Int16.Parse(hex, System.Globalization.NumberStyles.HexNumber);
            return b;
        }

        static void Read()
        {
            if (!socket.Connected)
            {
                socket.Connect("192.168.1.125", 10001);
            }
            var str = "@00RD1200000356*\r";
            var sendBuff = Encoding.Default.GetBytes(str);
            int sendInt= socket.Send(sendBuff);
            var buff = new byte[1024];
            int len = socket.Receive(buff);
            var result = Encoding.Default.GetString(buff, 0, len);
        }
             

        public static string FCS(string data)
        {
            int xorresult = 0;
            string tempfes = "";
            for (int i = 0; i < data.Length; i++)
            {
                xorresult = xorresult ^ Convert.ToInt32(data[i]);
            }
            tempfes = Convert.ToString(xorresult, 16);
            if (tempfes.Length == 1)
            {
                tempfes = "0" + tempfes;
            }
            return tempfes;
        }


        static void Com()
        {
            socket.Connect("192.168.1.98", 10001);

        }

    }
}
